﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Member.Model;
using Member.DAL;
using System.Linq.Expressions;
using Member.IBLL;
using Member.IDAL;

namespace Member.BLL
{
    public partial class UsersManagerBLL:BaseBLL<User>,IUsersManageBLL
    {
        //private UsersManagerDAL userdal = new UsersManagerDAL();
        private IUsersManageDAL userdal = new UsersManagerDAL();

        public override void setDAl()
        {
            Dal = userdal;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        public bool delete(int id)
        {
            var s = userdal.GetModels(p => p.user_id == id).FirstOrDefault();
            userdal.Delete(s);
            return userdal.SaveChange();
        }
        /// <summary>
        /// 查询该电话号码是否注册
        /// </summary>
        /// <returns></returns>
        public bool istell(string tell)
        {
            if (userdal.isuser(p => p.user_tel == tell) != null)
            {//存在
                return true;
            }
            //不存在
            return false;
        }
        /// <summary>
        /// 根据查询条件获取总数量
        /// </summary>
        /// <param name="WhereLambda">条件</param>
        /// <returns></returns>
        public int maxshow(Expression<Func<User, bool>> WhereLambda)
        {
            int max = userdal.GetModels(WhereLambda).Count();
            return max;
        }
    }
}
